<%--
  Created by IntelliJ IDEA.
  User: ZhuChunXiao
  Date: 2017/5/24
  Time: 16:59
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
  String _id=request.getParameter("_");
  String jsessionid = session.getId();
%>

<div class="row">
  <div class="col-lg-12">
    <div class="panel">
      <div class="panel-heading header">
        <h3 class="panel-title" id="title">员工调动申请表</h3>
      </div>

      <!-- BASIC FORM ELEMENTS -->
      <!--===================================================-->
      <form id="form_quit_input" class="panel-body form-horizontal form-padding">
        <input type="hidden" name="keyId" id="keyId" value="${quit.id}" />
        <input type="hidden" name="parentId" id="parentId" value="${parentId}" />
        <input type="hidden" name="curDutyId" id="curDutyId" value=""/>

        <div class="form-group">
          <label class="col-md-2 control-label">用人性质<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-6">
            <input disabled type="text" id="nature" name="nature" class="form-control" value="${personnelInfo.personnelUse.nature==1?"正式":"试用"}">
          </div>
        </div>

        <div class="form-group">
          <label class="col-md-2 control-label">
            姓名
            <i class="fa fa-asterisk txt-color-red"></i>
          </label>
          <div class="col-md-2">
            <input type="text" id="name" name="name" class="form-control" placeholder="请输入姓名" disabled value="${personnelInfo.name}">
          </div>

          <label class="col-md-2 control-label">
            身份证号
            <i class="fa fa-asterisk txt-color-red"></i>
          </label>
          <div class="col-md-2">
            <input type="text" id="cardId" name="cardId" class="form-control" placeholder="请输入身份证号" disabled value="${personnelInfo.cardId}">
          </div>
        </div>

        <div class="form-group">
          <label class="col-md-2 control-label">
            部门
            <i class="fa fa-asterisk txt-color-red"></i>
          </label>
          <div class="col-md-2">
            <input type="text" id="deptName" name="deptName" class="form-control" disabled value="${personnelInfo.department.name}">
          </div>

          <label class="col-md-2 control-label">
            岗位
            <i class="fa fa-asterisk txt-color-red"></i>
          </label>
          <div class="col-md-2">
            <input type="text" id="postName" name="postName" class="form-control"  disabled value="${personnelInfo.post.name}">
          </div>
        </div>

        <div class="form-group div-Hidden">
          <label class="col-md-2 control-label">合同开始日期<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-2">
            <div class="input-group date">
              <input disabled type="text" class="form-control" id="contractDateStart" name="contractDateStart" placeholder="请选择合同开始日期"
                     value=<fmt:formatDate pattern="yyyy-MM-dd" value="${personnelInfo.personnelUse.contractDateStart}" /> >
              <span class="input-group-addon"><i class="ti-calendar"></i></span>
            </div>
          </div>
          <label class="col-md-2 control-label">合同结束日期<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-2">
            <div class="input-group date">
              <input disabled type="text" class="form-control" id="contractDateEnd" name="contractDateEnd" placeholder="请选择合同结束日期"
                     value=<fmt:formatDate pattern="yyyy-MM-dd" value="${personnelInfo.personnelUse.contractDateEnd}" /> >
              <span class="input-group-addon"><i class="ti-calendar"></i></span>
            </div>
          </div>
        </div>

        <div class="form-group">
          <label class="col-md-2 control-label">离职性质<i class="fa fa-asterisk txt-color-red"></i>
            <span id="natureSpan" style="display: none">${quit.type}</span>
          </label>
          <div class="col-md-6">

            <div class="radio">
              <!-- Inline radio buttons -->
              <input type="radio" name="type" id="type1Selected" class="magic-radio" value="1"
              <c:if test="${quit.type eq 1}"> checked="checked"</c:if> >
              <label for="type1Selected">辞职</label>

              <input type="radio" name="type" id="type2Selected" class="magic-radio" value="2"
              <c:if test="${quit.type eq 2}"> checked="checked"</c:if> >
              <label for="type2Selected">辞退</label>

            </div>
          </div>
        </div>

        <div class="form-group">
          <label class="col-md-2 control-label">离职原因<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-6">
            <input type="text" id="reason" name="reason" class="form-control" placeholder="请输入离职原因" value="${quit.reason}">
          </div>
        </div>

        <div class="form-group">
          <label class="col-md-2 control-label">辞职报告<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-6">
            <input name="uploadify" id="filename" placeholder="" type="file" >
            <input name="fileId" id="fileId" style="display: none" value="${fileId}">
          </div>
        </div>

        <div class="form-group div-Hidden">
          <label class="col-md-2 control-label">预计离职日期<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-6">
            <div class="input-group date">
              <input type="text" class="form-control" id="date" name="date" placeholder="请选择预计离职日期"
                     value=<fmt:formatDate pattern="yyyy-MM-dd" value="${quit.date}" /> >
              <span class="input-group-addon"><i class="ti-calendar"></i></span>
            </div>
          </div>
        </div>

        <div class="form-group">
          <label class="col-md-2 control-label">备注</label>
          <div class="col-md-6">
            <input type="text" id="remarks" name="remarks" class="form-control" placeholder="请输入备注" value="${quit.remarks}">
          </div>
        </div>


        <div class="form-group">
          <label class="col-md-2 control-label">提交人</label>
          <div class="col-md-2">
            <p class="form-control-static">${quit.creater.name}</p>
          </div>
          <label class="col-md-2 control-label">提交日期</label>
          <div class="col-md-2">
            <p class="form-control-static"><fmt:formatDate pattern="yyyy-MM-dd" value="${quit.createTime}" /></p>
          </div>
        </div>

        <div class="panel-footer">
          <a class="btn btn-default" id="apply-re-common" href="javascript:void(0)">
            <i class="fa fa-lg fa-mail-reply"></i> 返回
          </a>
          <a class="btn btn-success" id="btn-save-common" href="javascript:void(0);"><i class="fa fa-lg fa-download"></i> 保存 </a>
          <c:if test="${quit==null || quit.processState=='Draft'}">
            <a class="btn btn-warning" id="btn-commit-common" href="javascript:void(0);"><i class="fa fa-upload"></i> 提交 </a>
          </c:if>
          <c:if test="${quit!=null && quit.processState=='Backed'}">
            <a class="btn btn-warning" id="btn-recommit-common" href="javascript:void(0);"><i class="fa fa-upload"></i> 再提交 </a>
          </c:if>
        </div>
        
      </form>
      <!--===================================================-->
      <!-- END BASIC FORM ELEMENTS -->
    </div>
  </div>
</div>

<script>
  var index = "${index}";
  var todo = "${todo}";
  var remind = "${remind}";
  var record = "${record}";
  var draft =  "${draft}";

  // 日期选择
  $('.input-group.date').datepicker({
    format: 'yyyy-mm-dd',
    weekStart: 1,
    autoclose: true,
    todayBtn: 'linked',
    todayHighlight: true,
    language: 'zh-CN'
  });

  $(function(){
    var pdata= {
      keyId:$("#keyId").val(),
      entityName:"com.fz.us.oa.core.entity.com.Quit"
    };
    multiDuty(pdata);
//    fn_dispatch_input_validate()
  });

  // 附件上传
  inputLoad({
    objId:"filename",
    entityName:"fileIds",
    sourceId:"fileId",
    jsessionid:"<%=jsessionid%>"
  });

  //校验
  function infoValidate() {
    var tmp = "";

    tmp = $('#form_quit_input input:radio[name="type"]:checked').val();
    if(!tmp){
      __toastr_error("请选择离职性质！");
      return false;
    }

    tmp = $("#form_quit_input #reason").val();
    if(!tmp){
      __toastr_error("请输入离职原因！");
      return false;
    }

    tmp = $("#form_quit_input #fileIds").val();
    if(!tmp){
      __toastr_error("请上传辞职报告！");
      return false;
    }

    tmp = $("#form_quit_input #date").val();
    if(!tmp){
      __toastr_error("请选择预计离职日期！");
      return false;
    }

    return true;
  }

  //保存
  $("#btn-save-common").click(
          function(e) {
            __confirm_dialog("提示：","确定保存吗？",
                    function () {
                      __form_save("form_quit_input", "<%=path%>/com/quit/save",function(){
                        $("#apply-re-common").trigger("click");
                      });
                    }
            )
          }
  );

  //提交
  $("#btn-commit-common,#btn-recommit-common").click(
          function(e) {
            var $valid = infoValidate();
//                console.log("v:"+$valid);
            if(!$valid) return false;

            __confirm_dialog("提示：","提交后填写资料不得修改，请确认是否进行提交？",
                    function () {
                      __form_save("form_quit_input", "<%=path%>/com/quit/submit",function(){
                        $("#apply-re-common").trigger("click");
                      });
                    }
            )
          }
  );

  //返回视图
  $("#apply-re-common").click(function(){
    if(index==1){
      loadURL("menu/dashboard",$('#page-content'));
    }else if(todo==1){
      loadURL("menu/toDo",$('#page-content'));
    }else if(remind==1){
      loadURL("menu/remind",$('#page-content'));
    }else if(record==1){
      loadURL("menu/taskRecord?type=1",$('#page-content'));
    }else if(record==2){
      loadURL("menu/taskRecord?type=2",$('#page-content'));
    }else if(draft==1){
      loadURL("menu/draft",$('#page-content'));
    }else{
      returnToHashUrl()
    }
  });


</script>